package model.player;

import java.util.List;

import model.map.GameTile;
import model.mapping.PlayableMapping;
import model.playable.unit.Unit;

public abstract class UnitManager implements PlayableManager, UnitUpdatable
{
	private PlayableMapping playableMapping = PlayableMapping.getPlayableMapping();
	private Player player;
	private ResourceManager resourcePool;
	private String type;
	
	public UnitManager(Player player, ResourceManager rm, String type)
	{
		this.player = player;
		resourcePool = rm;
		this.type = type;
	}
	
	public String getType()
	{
		return type;
	}
	
	public Player getPlayer()
	{
		return player;
	}
	
	public abstract Unit getUnit(int id);
	
	public PlayableMapping getPlayableMapping()
	{
		return playableMapping;
	}
	
	public abstract void createNewUnit(GameTile tile);

	public void addUnitToMap(GameTile tile, Unit u)
	{
		playableMapping.addUnit(tile, u);
	}

	public void removeFromMap(Unit u)
	{
		playableMapping.removeUnit(u);
		
	}

	public int grabFood(int amount)
	{
		return resourcePool.takeFood(amount);
	}
	
	public int grabOre(int amount)
	{
		return resourcePool.takeOre(amount);
	}
	
	public int grabEnergy(int amount)
	{
		return resourcePool.takeEnergy(amount);
	}
	
	public abstract List<Unit> getAllUnits();
}
